package net.lab1024.sa.admin.module.business.bjd.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import net.lab1024.sa.admin.module.business.bjd.domain.form.DollAddForm;
import net.lab1024.sa.admin.module.business.bjd.domain.form.DollDeleteForm;
import net.lab1024.sa.admin.module.business.bjd.domain.form.DollQueryForm;
import net.lab1024.sa.admin.module.business.bjd.domain.form.DollUpdateForm;
import net.lab1024.sa.admin.module.business.bjd.domain.vo.DollVO;
import net.lab1024.sa.admin.module.business.bjd.service.DollService;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 *
 * @author guolong.zhang
 * @date 2025/02/09 09:41
 **/
@RestController
@Tag(name = "娃娃信息管理")
public class DollController {

    @Autowired
    private DollService dollService;

    @Operation(summary = "分页查询")
    @PostMapping("/bjd/doll/queryPage")
    public ResponseDTO<PageResult<DollVO>> queryPage(@RequestBody @Valid DollQueryForm queryForm) {
        return ResponseDTO.ok(dollService.queryPage(queryForm));
    }

    @Operation(summary = "新增")
    @PostMapping("/bjd/doll/add")
    public ResponseDTO<Void> add(@RequestBody @Valid DollAddForm addForm) {
        dollService.add(addForm);
        return ResponseDTO.ok();
    }

    @Operation(summary = "根据id查询")
    @PostMapping("/bjd/doll/detail")
    public ResponseDTO<DollVO> detail(@RequestBody @Valid DollDeleteForm req) {
        return ResponseDTO.ok(dollService.detail(req));
    }

    @Operation(summary = "修改")
    @PostMapping("/bjd/doll/update")
    public ResponseDTO<Void> update(@RequestBody @Valid DollUpdateForm updateForm) {
        dollService.update(updateForm);
        return ResponseDTO.ok();
    }
    @Operation(summary = "删除")
    @PostMapping("/bjd/doll/delete")
    public ResponseDTO<Void> delete(@RequestBody @Valid DollDeleteForm req) {
        dollService.delete(req);
        return ResponseDTO.ok();
    }

}
